using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
	public partial class Geo_PostcodesComponent
    {
	
        /// <summary>
        /// Selects one record from the database table using the primary key.
        /// </summary>
        /// <returns>An object of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public Geo_Postcodes SelectOneWTownCode(string TownCode)
        {
            PlacementManager.DAL.Geo_Postcodes_DAL o = new PlacementManager.DAL.Geo_Postcodes_DAL();
            DataTable dt = o.SelectOneWTownCode(TownCode).Tables[0];

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                PlacementManager.Geo_Postcodes Geo_PostcodesToReturn = new PlacementManager.Geo_Postcodes((int)row["PostCodeId"], (string)row["TownCode"], (string)row["State"], (short)row["Postcode"]);
                return Geo_PostcodesToReturn;
            }
            else
            {
                PlacementManager.Geo_Postcodes Geo_PostcodesToReturnEmpty = new PlacementManager.Geo_Postcodes();
                return Geo_PostcodesToReturnEmpty;
            }
        }
    }
}